<template>
	<div id="app">
		<main>
			<enter-leave :mode="$route.meta.mode">
				<keep-alive>
					<router-view v-if="$route.meta.keepAlive"></router-view>
				</keep-alive>
			</enter-leave>
			<enter-leave :mode="$route.meta.mode">
				<router-view v-if="!$route.meta.keepAlive"></router-view>
			</enter-leave>
		</main>
		<keep-alive>
			<router-view name="footer"></router-view>
		</keep-alive>
		<!--<loading />-->
	</div>
</template>

<script>
	import loading from '#/Public/loading';
	import {mapState, mapActions} from 'vuex';

	export default {
		name: 'app',
		computed: {
			...mapState(['user'])
		},
		methods: {
			...mapActions(['getUserDetail'])
		},
		components: {
			enterLeave: () => import('#/Public/enter-leave'),
			loading
		},
		created() {
			if (this.user.token && !this.user.isLogin) {
				this.getUserDetail(this.user.token);
			}
			this.$message({
				type: 'success',
				message: '郝晨光制作！'
			})
		},
		errorCaptured(err) {
			console.log(err + '在App组件内补获错误');
		}
	}
</script>
